package com.lk.oauth2.web.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lk.oauth2.web.entity.SysUser;
import com.lk.oauth2.web.mapper.SysUserMapper;
import com.lk.oauth2.web.service.SysUserService;

/**
 * 用户表 服务实现类
 *
 * @author Aspirin
 * @since 2020-06-21
 */
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser>
    implements SysUserService {

  @Override
  public SysUser findByUsername(String username) {
    if (StringUtils.isEmpty(username)) {
      return null;
    }
    QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
    queryWrapper.eq("username", username);
    return baseMapper.selectOne(queryWrapper);
  }

  @Override
  public SysUser findByMobile(String mobile) {
    if (StringUtils.isEmpty(mobile)) {
      return null;
    }
    QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
    queryWrapper.eq("mobile", mobile);
    return baseMapper.selectOne(queryWrapper);
  }
}
